from typing import List
class Solution:
    def rankTeams(self, votes: List[str]) -> str:
        n = len(votes[0])
        r = {}
        for i in votes:
            for index, j in enumerate(i):
                if j not in r:
                    r[j] = [0] * n
                r[j][index] += 1
        print(r)

        l = list(r.keys())

        def mysort(l, x):
            return l, 0- ord(x)
                      
        # l.sort(key=mysort)
        print(sorted(l, key=lambda x :mysort(r[x], x), reverse=True))





if __name__ == "__main__":
    votes = ["ABC","ACB","ABC","ACB","ACB"]
    # votes = ["BCA","CAB","CBA","ABC","ACB","BAC"]
    print(Solution().rankTeams(votes)) # "ACB"
